<?php
// ----------------------------------------------------------------------
// POSTNUKE Content Management System
// Copyright (C) 2001 by the PostNuke Development Team.
// http://pncommerce.de
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Source file:  $Source: /cvsroot/pn-commerce/pn-commerce/pnblocks/lastorder.php,v $
//
// Last changes from:  $Author: pcornelissen $
//
// Revision:           $Revision: 1.6 $
//
// Date of revision    $Date: 2003/12/05 14:11:20 $
//  
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------

function pncommerce_lastorderblock_info()
{
    return array('text_type' => 'pncommerce_Block',
                 'module' => 'pncommerce',
                 'text_type_long' => 'Show last item ordered Block',
                 'allow_multiple' => true,
                 'form_content' => false,
                 'form_refresh' => false,
                 'show_preview' => true);
}

function pncommerce_lastorderblock_init()
{
    // Security
    pnSecAddSchema('pncommerce:LastItemOrderedBlock:', 'Block title::');
}

function pncommerce_lastorderblock_display($row)
{

	if (!pnSecAuthAction(0, 'pncommerce:LastItemOrderedBlock:', $row['title']."::", ACCESS_READ))
	{
		return;
	}

	// load the api to read database info for the items
	if (!pnModAPILoad('pncommerce', 'user'))
	{
      	return false;
	}

	// Break out options from our content field
	$vars = pnBlockVarsFromContent($row['content']);

    $smarty = new pnRender('pncommerce');
    $smarty->caching = false;
    $smarty->assign( 'item', pnModAPIFunc( 'pncommerce', 'user', 'getItem',
    				 array( 'ItemID' => pnModGetVar( 'pncommerce', 'LastItemOrdered' ) ) ) );
	$row['content'] = $smarty->fetch( 'pncommerce_block_lastitemordered.html' );
	return themesideblock($row);
}

?>
